import java.util.concurrent.TimeUnit;

public class Worker extends Thread{
    private UrgentTask joiner;
    public void run(){
        int i=0;
        while(i<9){
            try {
                    if(i==6){
//                        UrgentTask urgent = new UrgentTask();
                        System.out.println("突然接到紧急任务需要完成");
                        this.joiner.start();
                        this.joiner.join();
                    }
                    System.out.println("我正在做日常工作。完成度"+i*10+"%+++++++++++++++++++++++");
                    TimeUnit.SECONDS.sleep(2);
                    i+=2;
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
        }
        System.out.println("我已经完成了日常工作，完成度100%++++++++++++++++++++");
    }
    public void setJoiner(UrgentTask joiner){
                 this.joiner=joiner;
    }
}
